import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from "../views/Home.vue"
import Hot from "../views/Hot.vue"
import About from "../views/About.vue"
import Detail from "../views/Detail.vue"

import Main from "../components/Main.vue"
import Other from "../components/Other.vue"

Vue.use(VueRouter)

const router = new VueRouter({
  mode:"history", // 路由模式 hash|history  
  routes: [
    {
      path: "/home", // http://localhost:8080/home
      component: Home,
      children: [
        {
          path: "main",
          component:Main
        },
        {
          path: "other",
          component: Other
        },
        {
          path: "",
          redirect:"main"
        }
      ]
    },
    {
      path: "/hot", // http://localhost:8080/good
      component:Hot
    },
    {
      path: "/about", // http://localhost:8080/good
      component:About
    },
    {
      path: "/detail", // http://localhost:8080/good 
      component: Detail,
      name: "myDetail" //命名路由
    },
    {
      path: "*", // 当上面的路由完全不匹配时，走这里
      redirect:"/home" // 重定向到路由 /home中
    }
  ]
})
export default router
